/******************************************************************************
 * Copyright (C) 2015  671643387@qq.com
 *
 * This program is free software; you can redistribute it and/or modify it
 * under the terms of the GNU General Public License as published by the
 * Free Software Foundation; either version 2 of the License, or
 * (at your option) any later version.
 *
 * This program is distributed in the hope that it will be useful, but WITHOUT
 * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
 * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for
 * more details.
 *
 * You should have received a copy of the GNU General Public License along
 * with this program; if not, write to the Free Software Foundation, Inc.,
 * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
 *
 *****************************************************************************/

#ifndef SHARED_UTIL_WORLDPACKET_H_
#define SHARED_UTIL_WORLDPACKET_H_

#if defined(_MSC_VER) && (_MSC_VER >= 1200)
# pragma once
#endif

#include <cstddef>
#include <cstdint>
#include "Ucop/Binary/ByteBuffer.h"
#include "Shared/Opcodes.h"


class WorldPacket : public Ucop::Binary::ByteBuffer
{
public:
	WorldPacket(void)
		: ByteBuffer(0)
		, _Myopcode(MSG_NULL_ACTION)
	{

	}

	explicit WorldPacket(std::uint16_t _Opcode, std::size_t _Res = 200)
		: ByteBuffer(_Res)
		, _Myopcode(_Opcode)
	{

	}

	WorldPacket(const WorldPacket& _Packet)
		: ByteBuffer(_Packet)
		, _Myopcode(_Packet._Myopcode)
	{

	}

	virtual ~WorldPacket(void) {}

	void Initialize(std::uint16_t _Opcode, std::size_t _Newres = 200)
	{
		Clear();
		_Mystorage.reserve(_Newres);
		_Myopcode = _Opcode;
	}

	inline std::uint16_t opcode(void) const {
		return _Myopcode;
	}
	inline void SetOpcode(std::uint16_t _Opcode) {
		_Myopcode = _Opcode;
	}

private:
	std::uint16_t _Myopcode;
};

#endif /* SHARED_UTIL_WORLDPACKET_H_ */
